package me.youline.dataServer.dao.socialActionMsg;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import me.youline.dataServer.entity.socialActionMsg.SocialActionPraiseMsg;

import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Component;

/**
 * 社交行为通知消息点赞通知DAO
 * @author linhan
 *
 */
@Component
public class SocialActionPraiseMsgDAO extends
		AbstractSocialActionMsgDAO<SocialActionPraiseMsg> {
	
	private static final String TABLE_NAME = "yline_social_notice_msg_praise";
	
	private static final RowMapper<SocialActionPraiseMsg> ROW_MAPPER = new SocialActionMsgRowMapper<SocialActionPraiseMsg>(new SocialActionPraiseMsg()){

		@Override
		protected void doSpecialMapRow(SocialActionPraiseMsg msg, ResultSet rs,
				int rowNum) throws SQLException {
			msg.setMsgPicUrl(rs.getString("msgPicUrl"));
			msg.setMsgTitle(rs.getString("msgTitle"));
		}
	};
	
	@Override
	protected void initMsgAddData(SocialActionPraiseMsg msg,
			Map<String, Object> map) {
		map.put("msgPicUrl", msg.getMsgPicUrl());
	}


	
	/**
	 * 根据发起人及其操作的原创公告ID获取通知ID
	 * @param initiatorId
	 * @param originId
	 * @return
	 */
	public List<Long> getMsgIdsByInitiatorAndOriginId(Long initiatorId, Long originId){
		ConditionBuilder builder = new ConditionBuilder();
		builder.addEqCondition("targetId", originId);
		builder.addEqCondition("initiator", initiatorId);
		return this.getMsgIdsByCondition(builder);
	}
	
	
	
	@Override
	protected String getTableName() {
		return TABLE_NAME;
	}

	@Override
	protected RowMapper<SocialActionPraiseMsg> getEntityInnerRowMapper() {
		return ROW_MAPPER;
	}

}
